﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CustomerOrderingSystem
{
    public partial class Goods : Form
    {
        private string sql = "";
        public Goods()
        {
            InitializeComponent();
        }

        
        private void MakeSqlStr()
        {
            sql = "";
            if (gnoTextBox.Text.Trim() != string.Empty)
            {
                sql = "and Gno ='" + gnoTextBox.Text.Trim() + "'";
            }
            if (gnameTextBox.Text.Trim() != string.Empty)
            {
                sql += "and Gname ='" + gnameTextBox.Text.Trim() + "'";
            }
        }

        private void Goods_Load(object sender, EventArgs e)
        {
            goodsDataGridView.DataSource = sql_good.QueryDataTable0();
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            MakeSqlStr();
            goodsDataGridView.DataSource = sql_good.QueryDataTable(sql);
        }
    }
}